//
//  BKJPayWaysTableViewCell.m
//  BKJ
//
//  Created by 贝壳家iOS on 15/11/5.
//  Copyright © 2015年 贝壳家iOS. All rights reserved.
//

#import "BKJPayWaysTableViewCell.h"

@interface BKJPayWaysTableViewCell ()

@property (nonatomic, strong) UIButton *button;

@end


@implementation BKJPayWaysTableViewCell

- (void)awakeFromNib {
    // Initialization code
}



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _imgView = [UIImageView new];
        [self.contentView addSubview:_imgView];
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView);
            make.left.equalTo(self.contentView).offset(10);
            make.size.mas_equalTo(CGSizeMake(25*MIX_W, 25*MIX_W));
        }];
        
        
        _label = [UILabel new];
        [self.contentView addSubview:_label];
        [_label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView);
            make.left.equalTo(_imgView.mas_right).offset(10);
        }];
      
      [self.contentView addSubview:self.button];
      [self.button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.right.equalTo(self.contentView).offset(-20);
      }];
      
      @weakify(self)
      [RACObserve(self, selected) subscribeNext:^(NSNumber *select) {
        @strongify(self)
        self.button.selected = select.boolValue;
      }];
      
    }
    return self;
}


- (UIButton *)button{
  if (!_button) {
    _button = [UIButton buttonWithType:UIButtonTypeCustom];
    [_button setImage:[UIImage imageNamed:@"Not checked-1"] forState:UIControlStateNormal];
    [_button setImage:[UIImage imageNamed:@"Check"] forState:UIControlStateSelected];
  }
  return _button;
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
